//九九乘法表
/*for (let i = 1; i < 10; i++) {
    for (let j = 1; j <= i; j++) {
        document.write(j + '*' + i + '=' + j * i + '&nbsp;&nbsp;&nbsp;&nbsp;')
    }
    document.write('<br>')
}*/
//输出1-200之间的质数，10个一行
function fn3() {
    for (let i = 2; i < 200; i++) {
        let j = 2
        while (i % j !== 0) {
            j++
        }
        if (j === i) {
            document.write(`<div class='item'>${i}</div>`)
            count++
            if (count % 10 === 0) {
                document.write(`<br>`)
            }

        }
    }
}
//fn3()

//输入层高n层的等腰三角形
function fn4() {
    let n = prompt('输入层高')
    if (isNaN(n)) {
        alert('请输入整数')
        fn4()
    }
    n = parseInt(n)
    //外层循环
    for (let i = 0; i < n; i++) {
        //左边的倒直角三角形
        for (let j = 0; j < n - i - 1; j++) {
            document.write(`<div class='items'></div>`)
        }
        //右边的等腰三角形
        for (let k = 0; k < 2 * i + 1; k++) {
            document.write(`<div class='items'>*</div>`)
        }
        //换行
        document.write(`<br>`)
    }
}
fn4()